%%

%byaccj

%{
  /* store a reference to the parser object */
  private Parser yyparser;

  /* constructor taking an additional parser object */
  public Yylex(java.io.Reader r, Parser yyparser) {
    this(r);
    this.yyparser = yyparser;
  }
%}

IF = "if"
ELSE = "else"
FOR = "for"
WHILE = "while"
BREAK = "break"
CONTINUE = "continue"
RETURN = "return"
NEW = "new"
FUNCTION = "function"
TYPE = "int"|"double"|"float"|"boolean"|"String"|"void"|"Image"|"ImageMatrix"|"Kernel"|"Color"|"Alignment"             
TRUE = "true"
FALSE = "false"
CHAR = [a-zA-Z_]
NUM = {DIGIT}+
FLOAT = ( ({DIGIT}*{DOT}{DIGIT}+) | ({DIGIT}+{DOT}{DIGIT}*) )(E[+|-]? {DIGIT}+)?
DIGIT = [0-9]
ID = {CHAR}({CHAR}|{DIGIT})*
GASID = "#"{CHAR}({CHAR}|{DIGIT})*
WS = [ \t\n\r]+
STRING = \" [^\"]* \"
LPAREN = "("
RPAREN =  ")"
DOT = "."
MULT = "*"
PLUS = "+"
MINUS =  "-"
DIV = "/"
POWER = "^"
OR = "||"
AND = "&&"
NOT = "!"
SEMI = ";"
LBRACE =  "{"
RBRACE  =  "}"
LBLK =  "["
RBLK =  "]"
ASGN = "="
COMMA = ","
GE = ">="
LE = "<="
GT = ">"
LT =   "<"
EQL = "=="
NEQL = "!="
SHARP = "#"
LINE_COMMENT = "//".*\n
MULTI_COMMENT = "/*" ([^"*/"])* "*/"

%%


{IF}   { return Parser.IF; }



{ELSE} {return Parser.ELSE;}

{FOR} {return Parser.FOR;}

{WHILE} {return Parser.WHILE;}

{BREAK} {return Parser.BREAK;}

{CONTINUE}  {return Parser.CONTINUE;}

{RETURN} {return Parser.RETURN;}

{NEW} {return Parser.NEW;}

{FUNCTION} {return Parser.FUNCTION;}

{TYPE} {yyparser.yylval = new ParserVal(String.valueOf(yytext())); return Parser.TYPE; }
       
{TRUE} {yyparser.yylval = new ParserVal(String.valueOf(yytext())); return Parser.TRUE;}

{FALSE} {yyparser.yylval = new ParserVal(String.valueOf(yytext())); return Parser.FALSE;}

{NUM}  { yyparser.yylval = new ParserVal(Integer.parseInt(yytext()));
 return Parser.NUM; }

{FLOAT} {yyparser.yylval = new ParserVal(Double.parseDouble(yytext()));
 return Parser.FLOAT; }

{ID}       {yyparser.yylval = new ParserVal(String.valueOf(yytext())); return Parser.ID;}

{GASID} {yyparser.yylval = new ParserVal(String.valueOf(yytext())); return Parser.GASID;}

{WS} {}
{STRING} {yyparser.yylval = new ParserVal(String.valueOf(yytext())); return Parser.STRING; }   
{LPAREN} {return Parser.LPAREN;}
{RPAREN} {return Parser.RPAREN;}
{DOT}    {return Parser.DOT;}
{MULT}  {return Parser.MULT;}
{PLUS}    {return Parser.PLUS;}
{MINUS}  {return Parser.MINUS;}
{DIV}        {return Parser.DIV;}
{POWER}  {return Parser.POWER;}
{AND}        {return Parser.AND;}
{OR}          {return Parser.OR;}
{NOT}        {return Parser.NOT;}
{SEMI}       {return Parser.SEMI;}
{LBRACE}  {return Parser.LBRACE;}
{RBRACE}  {return Parser.RBRACE;}
{LBLK}        {return Parser.LBLK;}
{RBLK}        {return Parser.RBLK;}
{ASGN}        {return Parser.ASGN;}
{COMMA}    {return Parser.COMMA;}
{GE}              {return Parser.GE;}
{LE}               {return Parser.LE;}
{GT}               {return Parser.GT;}
{LT}                {return Parser.LT;}
{EQL}              {return Parser.EQL;}
{NEQL}           {return Parser.NEQL;}
{SHARP}         {return Parser.SHARP;}
{LINE_COMMENT} {}
{MULTI_COMMENT} {}


